﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using StripeOne.ShortenUrl.API.Common;
using StripeOne.ShortenUrl.Model;
using StripeOne.ShortenUrl.Database;

namespace StripeOne.ShortenUrl.API.Client
{
    public class ShortenClient : BaseClient
    {
        public ShortenClient(string serviceRootUrl)
            : base(serviceRootUrl)
        {
        }

        public ShortenClient(string serviceRootUrl, int language, bool userSignature, string consumerKey, string consumerSecret)
            : base(serviceRootUrl, consumerKey, consumerSecret, language, userSignature)
        {
        }

        public ShortenApiResult<ShortenModel> ShorIt(int userId, string url)
        {
            var parameters = new Dictionary<string, object>();
            parameters["UserId"] = userId;
            parameters["Url"] = url;
            var ret = this.ExecuteApiCall<ShortenModel, ShortenClassSerializer>("Shorten", "ShortIt", parameters, ShortenApiMethod.POST);
            return ret;
        }

        public ShortenApiResult<ShortenModel> Get(int id)
        {
            var parameters = new Dictionary<string, object>();
            parameters["id"] = id;
            var ret = this.ExecuteApiCall<ShortenModel, ShortenClassSerializer>("Shorten", "Get", parameters, ShortenApiMethod.GET);
            return ret;
        }

        public ShortenApiResult<ShortenModel[]> GetAll(int userId)
        {
            var parameters = new Dictionary<string, object>();
            parameters["userId"] = userId;
            var ret = this.ExecuteApiCall<ShortenModel[], ShortenClassSerializer>("Shorten", "GetAll", parameters, ShortenApiMethod.GET);
            return ret;
        }
    }
}
